package com.usian.admin.controller.v1;

import com.usian.admin.service.AdChannelService;
import com.usian.apis.AdChannelControllerApis;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.PageResponseResult;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/v1/adchannel")
public class AdChannelController implements AdChannelControllerApis {
    @Autowired
    private AdChannelService adChannelService;

    @Override
    @RequestMapping("list")
    public ResponseResult findAll(@RequestBody ChannelDto dto) {
        return adChannelService.findAll(dto);
    }

    @Override
    @RequestMapping("save")
    public ResponseResult add(@RequestBody AdChannel adChannel) {
        return adChannelService.add(adChannel);
    }

    @Override
    @RequestMapping("upById")
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return adChannelService.updateAd(adChannel);
    }

    @Override
    @RequestMapping("deleteById/{id}")
    public ResponseResult deleteById(@PathVariable Integer id) {
        return adChannelService.deleteById(id);
    }
}
